-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Terraform plugin sdk v2 #67
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me 👍
( I added some notes for me 😬 and I'd like to upgrade the SDK for https://github.com/mercari/terraform-provider-openpgp as well )
var debugMode bool | ||
|
||
flag.BoolVar(&debugMode, "debuggable", false, "set to true to run the provider with support for debuggers like delve") | ||
flag.Parse() | ||
|
||
if debugMode { | ||
err := plugin.Debug(context.Background(), "registry.terraform.io/mercari/spinnaker", | ||
&plugin.ServeOpts{ | ||
ProviderFunc: spinnaker.Provider, | ||
}) | ||
if err != nil { | ||
log.Println(err.Error()) | ||
} | ||
} else { | ||
plugin.Serve(&plugin.ServeOpts{ | ||
ProviderFunc: spinnaker.Provider}) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[note]
This is new implementation for Debuggable Provider Binary:
https://www.terraform.io/docs/extend/guides/v2-upgrade-guide.html#support-for-debuggable-provider-binaries
@@ -35,6 +36,6 @@ func datasourceApplication() *schema.Resource { | |||
Computed: true, | |||
}, | |||
}, | |||
Read: resourceSpinnakerProjectRead, | |||
ReadContext: resourceSpinnakerApplicationRead, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just question, the previous implementation was incorrect, right? ( It should have been Application
, not Project
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it was incorrect 🙇
@@ -45,6 +46,6 @@ func datasourceCanaryConfig() *schema.Resource { | |||
}, | |||
}, | |||
}, | |||
Read: resourceSpinnakerCanaryConfigRead, | |||
ReadContext: resourceSpinnakerCanaryConfigRead, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[note]
More Support for context.Context
for example, the helper/schema.CreateFunc, helper/schema.UpdateFunc, helper/schema.ReadFunc, and helper/schema.DeleteFunc types all got context-aware versions (helper/schema.CreateContextFunc, helper/schema.UpdateContextFunc, helper/schema.ReadContextFunc, helper/schema.DeleteContextFunc, respectively). The old versions are now deprecated, and we recommend you upgrade to the context-aware versions to get their improvements, ...
) | ||
|
||
var testAccProviders map[string]terraform.ResourceProvider | ||
var testAccProviders map[string]*schema.Provider |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[note]
Removal of the terraform.ResourceProvider Interface
The terraform.ResourceProvider interface has been removed. The concrete *helper/schema.Provider type should be used in its place.
@@ -88,32 +91,34 @@ type Permissions struct { | |||
Write []string `json:"WRITE"` | |||
} | |||
|
|||
func resourceSpinnakerApplicationCreate(d *schema.ResourceData, meta interface{}) error { | |||
func resourceSpinnakerApplicationCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[note]
Support for Diagnostics
A number of new functions have been added that return a diag.Diagnostics type. This type can be used to return multiple errors and warnings to Terraform, and to associate those errors or warnings with specific fields.
return nil | ||
} | ||
|
||
func resourceSpinnakerApplicationExists(d *schema.ResourceData, meta interface{}) (bool, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[note]
Deprecation of helper/schema.ExistsFunc
The helper/schema.ExistsFunc (usually set as the Exists property on helper/schema.Resource) is now deprecated.
Thank you for your review 🙇 |
Update Terraform plugin sdk v2 Signed-off-by: KeisukeYamashita <19yamashita15@gmail.com>
WHAT
Updated
WHY
Ref